export default class KeyCodeMap
{

    private static KEYCODE_CHAR=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
    private static KEYCODE_CHAR_SHIFT=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']

    private static KEYCODE_NUM=['0','1','2','3','4','5','6','7','8','9']
    private static KEYCODE_NUM_SHIFT=[')','!','@','#','$','%','^','&','*','(']

    /**
     * 从键盘码获取对应字符
     * @param keyCode 键盘码
     * @param isShiftDown 是否按下Shift
     */
    public static getCharFromKeyCode(keyCode:number,isShiftDown:boolean)
    {
        //获取大小写字符
        if(keyCode>=65&&keyCode<=90)
        {
            //初始化索引
            let idx=keyCode-65
            return isShiftDown ? this.KEYCODE_CHAR_SHIFT[idx] : this.KEYCODE_CHAR[idx]
        }
        //获取数字和符号
        if(keyCode>=48&&keyCode<=57)
        {
            //初始化索引
            let idx=keyCode-48
            //通过isShiftDown的值返回相应的字符
            return isShiftDown ? this.KEYCODE_NUM_SHIFT[idx] : this.KEYCODE_NUM[idx]
        }

    }
}